//    Copyright (C) Kherty.  All rights reserved.
using System.Windows.Media;
using OpenLS.Core.Serialization;
using OpenLS.Drawing;

namespace OpenLS.Spreadsheet
{
    public class RgbColor : SpreadsheetColor
    {
        public override string ToString()
        {
            return color.ToString();
        }
        public RgbColor() { }
        public RgbColor(Color color)
        {
            this.color = color;
        }
        private Color color;

        public override Color GetColor(ColorScheme colorScheme)
        {
             { return color; }
        }
        public Color Color
        {
            get { return color; }
            set { color = value; }
        }
	
	

        public override int GetHashCode()
        {
            return color.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            RgbColor other = obj as RgbColor;
            if (other == null)
                return false;
            return other.color.Equals(color);
        }

        internal override void WriteXmlAs(string name, WriteContext context)
        {
            using (WriteContext c = context.Write(name))
            {
                int r = color.R;
                int g = color.G;
                int b = color.B;
                string str = "FF" + r.ToString("X2") + g.ToString("X2") + b.ToString("X2");
                c.SetString("rgb", str);
            }
        }
    }
}
